package com.example.hotelmanagement.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.annotation.Value;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;

@Configuration
public class BlockchainConfig {

    // 从 application.properties 中读取区块链节点 URL
    @Value("${blockchain.url}")
    private String blockchainUrl;

    // 配置 Web3j 连接到以太坊区块链
    @Bean
    public Web3j web3j() {
        return Web3j.build(new HttpService(blockchainUrl)); // 连接到区块链节点
    }
}
